package twinb.interest;

import java.util.HashMap;
import java.util.Map;

public class PersonInterestModel extends InterestModelBase<Long>
{
    public static final double w_rt = 0.5;
    public static final double w_reply = 0.3;
    public static final double w_log_n_followers = 0.2;
    public Map<Long,Integer> followers=new HashMap<Long,Integer>();
    
    public void retweet(long uid)
    {
        addInterest(uid, w_rt);
    }
    
    public void reply(long uid)
    {
        addInterest(uid, w_reply);
    }
    
    @Override
    public double getInterest(Long uid)
    {
        double decayableInterest = super.getInterest(uid);
        int nFollowers = getNFollowers(uid);
        return decayableInterest + w_log_n_followers * Math.log(nFollowers);
    }
    
    public void setNFollowers(long uid,int n)
    {
    	this.followers.put(uid,n);
    }
    
    // TODO: make Twinb a singleton; look for the particular user and return # of followers
    private int getNFollowers(long uid)
    {
        return this.followers.get(uid);
    }
}
